import {mapGetters} from 'vuex'

export default {
    computed: {
        ...mapGetters([
            'dictMap'
        ])
    },
    data(){
        return {
            baseUrl:process.env.VUE_APP_BASE_API,
        }
    },
    methods: {
        CollectionLabel(dictCode, value) {
            if (!dictCode || dictCode=='') return ''

            this.$store.dispatch('dict/CollectionLabel', {dictCode})
            const tmpObj = this.dictMap[dictCode]
            if (!tmpObj) return value
            let tmp = tmpObj.find(item => {
                return item.value === value
            })
            if (!tmp) {
                return value
            }
            return tmp.label
        },
        CollectionData(dictCode) {
            if (!dictCode || dictCode=='') return []
            this.$store.dispatch('dict/CollectionLabel', {dictCode})
            const tmpObj = this.dictMap[dictCode]
            if (!tmpObj) return []
            return tmpObj
        }
    }
}